package top.healthylife.gateway.platform.fh.api.api.sheshui;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.healthylife.gateway.core.service.ParentFace;
import top.healthylife.gateway.dto.annotation.ApiServiceExplain;
import top.healthylife.gateway.platform.fh.api.api.IUnifyHandler;
import top.healthylife.gateway.platform.fh.api.util.FhHttpUtil;
import top.healthylife.gateway.platform.fh.dto.sheshui.businessquery.req.FhReqBusinessQuerySheShuiGJBDto;
import top.healthylife.gateway.platform.fh.dto.sheshui.businessquery.res.FhResBusinessQuerySheShuiGJBDto;

/**
 * @author : GaoZeXi
 * @date 2021/11/1 11:17
 */
@Slf4j
@Service
@ApiServiceExplain(price = 20, apiName = "涉税高精版-企业查询", docUrl = "-", info = "涉税高精版-企业查询-数据类型:satparty_qs,satparty_chufa,satparty_fzc,satparty_xin,satparty_xuke,satparty_reg,")
public class FhBusinessQuerySheShuiGJBApi implements ParentFace<FhReqBusinessQuerySheShuiGJBDto, FhResBusinessQuerySheShuiGJBDto>, IUnifyHandler {
    private static final String DOMAIN = "query/sat";

    @Override
    public FhResBusinessQuerySheShuiGJBDto execute(FhReqBusinessQuerySheShuiGJBDto t) {
        t.checkDataType();
        JSONObject jsonObject = FhHttpUtil.HttpRequest(t, DOMAIN);
        if (jsonObject == null) {
            return new FhResBusinessQuerySheShuiGJBDto();
        }
        if (StrUtil.isBlank(t.getDataType())) {
            return fillAllFields(jsonObject, t,FhResBusinessQuerySheShuiGJBDto.class);
        } else {
            return  fillFieldsByDataType(jsonObject, t,FhResBusinessQuerySheShuiGJBDto.class);
        }
    }

}
